package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {
    @Insert("insert into t_setmeal_checkgroup values(#{setmealId},#{groupId})")
    void addCheckGroupAndSetmealIds(@Param("setmealId") int setmealId, @Param("groupId") Integer groupId);

    @Select("select  tcg.id,tcg.NAME,tcg.remark " +
            "from t_checkgroup tcg , t_setmeal_checkgroup tscg  " +
            "WHERE tscg.CHECKGROUP_ID = tcg.ID and tcg.is_delete=0 and tscg.SETMEAL_ID =#{sid}")
    List<CheckGroup> findCheckGroupsBySetmealId(@Param("sid") Integer sid);

    @Select("select count(tor.SETMEAL_ID) as value,ts.name " +
            "FROM t_setmeal ts , t_order tor " +
            "where ts.ID = tor.SETMEAL_ID " +
            "group by tor.SETMEAL_ID;")
    List<Map> getSetmealZhanBi();
}
